package jtk.project4.fleet.field;

import java.awt.Component;
import java.util.ArrayList;

import javax.swing.table.TableCellRenderer;

import jtk.project4.fleet.domain.Employee;
import jtk.project4.fleet.domain.MtcData;
import jtk.project4.fleet.domain.Vendor;
import nl.coderight.jazz.dialog.MessageType;
import nl.coderight.jazz.dialog.OptionDialog;
import nl.coderight.jazz.dialog.OptionType;
import nl.coderight.jazz.dialog.ReturnOptionType;
import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.SelectField;
import nl.coderight.jazz.form.field.TableField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.TableField.AutoResizeMode;
import nl.coderight.jazz.form.field.table.TableFieldColumn;
import nl.coderight.jazz.i18n.Message;
import nl.coderight.jazz.i18n.Message.Choice;
import nl.coderight.jazz.i18n.Message.Param;
import nl.coderight.jazz.view.StatusBar;
import jtk.project4.fleet.domain.Equipment;
import jtk.project4.fleet.event.MaintenanceDueDetailsEvent;
import jtk.project4.fleet.event.VendorEvent;
import jtk.project4.fleet.event.MaintenanceDueDetailsEvent.MaintenanceDueDetailsEventType;
import jtk.project4.fleet.event.VendorEvent.VendorEventType;

public class EquipmentRepairMaintenanceDueField extends GroupControl<MtcData> {
	private TableField<MtcData> repairField;
	private TableFieldColumn repairDue;
	private TableFieldColumn repairRepair;
	private TableFieldColumn repairWo;
	private TableFieldColumn repairRequested;
	private TableFieldColumn repairComments;
	
	private Message status;
	private StatusBar statusBar;
	
	public void handleEvent (MaintenanceDueDetailsEvent evt){
		MtcData selectedMtcData = repairField.getValue();
		switch(evt.getType()){
		case SELECT :
			ArrayList<Choice> choices = new ArrayList<Choice>();
			choices.add(new Choice(0, "status.message.none"));
			choices.add(new Choice(1, "status.message.one"));
			choices.add(new Choice(2, "status.message.all"));
			
			status = new Message("status.message");
			status.addParam(new Param(repairField.getValueCount()));
			status.addParam(new Param(repairField.getListOfValues().size(), choices));
			status.addParam(new Param(repairField.getSelectionCount()));
			// display message on status bar
			statusBar = new StatusBar();
			statusBar.setMessage(status);
		break;
		/*default:
			// propagate event to controller
			propagateEvent(evt);
			break;
		*/

		}
	}
	public EquipmentRepairMaintenanceDueField(String bindID){
		setTitle("header.equipmentrepairmaintenanceduefield");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	private void createFields() {
	
		repairField = new TableField("maintenanceDueDetailss","maintenanceDueDetails");
		repairField.setAutoResizeMode(AutoResizeMode.OFF);
		repairField.getSelectionValues();	
		repairField.setOnSelectEvent(new MaintenanceDueDetailsEvent(MaintenanceDueDetailsEventType.SELECT));

		repairDue = new TableFieldColumn("Due","nextDate");
		repairRepair = new TableFieldColumn("Repair","rprType");
		repairWo = new TableFieldColumn("WO#","wo");
		repairRequested = new TableFieldColumn("Requested By","reqBy");
		repairComments = new TableFieldColumn("Comments","notes");
		repairField.addColumn(repairDue);
		repairField.addColumn(repairRepair);
		repairField.addColumn(repairWo);
		repairField.addColumn(repairRequested);
		repairField.addColumn(repairComments);	
		
		
	}
	private void createLayout() {
		
		setLayout(new FormLayout())
		.addField(repairField);	
	}
}